namespace ScrumSprintMonitor.ConfigEditor.Views.ConfigurationView
{
	#region #using Directives

	using System;
	using System.Windows;
	using System.Windows.Input;

	using Microsoft.Practices.ServiceLocation;

	#endregion

	/// <summary>
	/// Interaction logic for ConfigurationWindow.xaml
	/// </summary>
	public partial class ConfigurationWindow : Window
	{
		private readonly IConfigurationViewModel model;

		public ConfigurationWindow()
		{
			InitializeComponent();
		}

		public ConfigurationWindow(IConfigurationViewModel model)
		{
			this.model = model;

			XamlServiceLocator.Assign(model);

			InitializeComponent();
		}

		public IConfigurationViewModel Model
		{
			get
			{
				if (this.model != null)
				{
					return this.model;
				}

				return ServiceLocator.Current.GetInstance<IConfigurationViewModel>();
			}
		}

		private void Window_Loaded(object sender, RoutedEventArgs e)
		{
			this.tfsServerNameComboBox.Focus();
		}

		private void Window_Activated(object sender, EventArgs e)
		{
			this.model.OnViewActivated();
		}

		private void Window_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
		{
			DragMove();
		}
	}
}